import recommend.recommend_algorithm_my as itemCF
import pandas as pd
import csv

# item = itemCF.ItemBasedCF()
# item.get_dataset()
# item.calc_movie_sim()
# result = item.evaluate()
#
# with open('rec_result.csv', 'w', newline='') as f:
#     writer = csv.writer(f)
#     for row in result.items():
#         writer.writerow(row)

with open('rec_result.csv', 'r') as f_result, open('movies.csv', 'r', encoding='utf-8') as f_movies:
    result = csv.reader(f_result)
    movie = csv.reader(f_movies)
    first_elements = set(row[0] for row in result)
    # 初始化 data 列表
    data = []
    # 遍历 movie 列表
    for row in movie:
        # 检查当前行的第二个元素是否在 first_elements 集合中
        if row[1] in first_elements:
            # 如果在，则将该行添加到 data 列表中
            data.append(row)



